<template>
  <div id="app">
    <Topbar :key="topBarKeyValue"></Topbar>

    <Header></Header>

    <!-- 提示框 -->
    <transition name="fade">
      <Toast v-show="isShowToast"></Toast>
    </transition>

    <Login v-show="isShowLoginModal"></Login>

    <router-view @reloadTopbarFn="reloadTopbar"></router-view>

    <Footer></Footer>
  </div>
</template>


<script>
import Topbar from "./components/Topbar.vue";
import Header from "./components/Header.vue";
import Footer from "./components/Footer.vue";
import Login from "./components/Login.vue";
import Toast from "./components/Toast.vue";
import { mapState } from "vuex";
export default {
  data() {
    return {
      topBarKeyValue: 1,
    };
  },
  methods: {
    //重载Topbar组件
    reloadTopbar() {
      //利用组件的key属性的值发生变化,组件就会重载的这个特点,让 Topbar组件的key值更新导致重载
      this.topBarKeyValue++;
    },
  },
  /*   watch: {
    "$route.path": {
      handler(oldVal, newVal) {
        //利用组件的key属性的值发生变化,组件就会重载的这个特点,让 Topban组件的key值更新导致重载

        this.topBarKeyValue++;
        console.log(oldVal, newVal);
      },
    },
  }, */
  components: {
    Topbar,
    Header,
    Footer,
    Login,
    Toast,
  },
  computed: {
    ...mapState({
      isShowLoginModal: (state) => state.showLogin.isShowLoginModal,
      isShowToast: (state) => state.ToastStatus.isShowToast,
    }),
  },
};
</script>


<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.8s;
}
.fade-enter,
.fade-leave-to {
  opacity: 0;
}
.fade-enter-to {
  opacity: 1;
}
</style>
